package com.googlecode.dgwt.client.dijit.event;

import com.google.gwt.user.client.Event;
import com.googlecode.dgwt.client.dijit.view.store.RowView;

/**
 * @author wellsantos@wellsantos.com
 * @since 0.01
 */
public class RowSelectEvent extends RowEvent<RowSelectHandler> {

    private static Type<RowSelectHandler> TYPE;
    
    protected RowSelectEvent(Event nativeEvent, int rowIndex, Object rowItem) {
        super(nativeEvent, rowIndex, rowItem);
    }
    
    public static void fire(RowView source, int rowIndex, Object rowItem){
        if (TYPE != null){
            source.fireEvent(new RowSelectEvent(null, rowIndex, rowItem));
        }
    }

    public static Type<RowSelectHandler> getType() {
        if (TYPE == null){
            TYPE = new Type<RowSelectHandler>();
        }
        return TYPE;
    }

    @Override
    protected void dispatch(RowSelectHandler handler) {
        handler.onRowSelect(this);
    }

    @Override
    public Type<RowSelectHandler> getAssociatedType() {
        return TYPE;
    }

}
